package kv

import (
	"fmt"
	"github.com/go-redis/redis"
	"mall_admin_api/biz/config"
)

var redisClient *redis.Client

func MustInit() {
	host := fmt.Sprintf("%s:%d", config.Values.Redis.Host, config.Values.Redis.Port)
	redisClient = redis.NewClient(&redis.Options{Addr: host, Password: config.Values.Redis.Auth})
	statusCmd := redisClient.Ping()
	if statusCmd.Err() != nil {
		panic(statusCmd.Err())
	}
}

func GetRedisClient() *redis.Client {
	return redisClient
}
